/* $Header: ix_cmds.c,v 2.2 01/10/02 10:29:19 przybyls Exp $ */

/***********************************************************************/
/*                                                                     */
/*                  Copyright Hewlett-Packard Co. 1991                 */
/*                                                                     */
/***********************************************************************/

/***********************************************************************/
/* MODULE NAME: ix_cmds.c                                              */
/* ============                                                        */
/*                                                                     */
/* Author:  Bob Cook                                                   */
/*                                                                     */
/* MODULE PURPOSE: This module will handle the injector commands.      */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

/*
 */ 

/*****************************/
/*   GLOBAL INCLUDE FILES    */
/*****************************/

#include <typedefs.h>

#include <error.h>

#include <mio.h>
#include <cmd_set.h>
#include <cmdproc.h>
#include <method.h>
#include <hostutil.h>
#include <cmd_tbls.h>


/*****************************/
/*   LOCAL INCLUDE FILES     */
/*****************************/



/*****************************/
/*   GLOBAL VARIABLES        */
/*****************************/


/*****************************/
/*   EXTERNAL VARIABLES      */
/*****************************/


/*****************************/
/*   LOCAL DEFINES           */
/*****************************/

/* if BC_DEBUG is defined debug buffers are created and statics become global */
#define BC_DEBUG

/* when debugging make variables global for emulator testing */
#ifdef BC_DEBUG
#   define SCOPE
#else
#   define  SCOPE  static
#endif


/*****************************/
/*   STATIC VARIABLES        */
/*****************************/



/*****************************/
/*   MACROS                  */
/*****************************/



/*****************************/
/*   IMPLEMENT SECTION       */
/*****************************/



/***********************************************************************/
/* FUNCTION: DoIXEO                                                    */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: Echo command.                                              */
/*                                                                     */
/* RETURNED VALUE: length of response string                           */
/*                                                                     */
/* WARNINGS:                                                           */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

INT16 DoIXEO(CMD_TYPE *p_cmd,BIT8  *p_resp_parm)
{
U_INT16 len;

   len = 0;

   if (p_cmd->parmv[0] == 1)
   {
      len = PutAsciiParam((BIT8 *)"\"", p_resp_parm);
      len += PutAsciiParam((BIT8 *)&(p_cmd->parms[p_cmd->parmv[1]]),
				     p_resp_parm+len);
      len += PutAsciiParam((BIT8 *)"\"", p_resp_parm+len);
      return len;
   }
   else
   {
      CmdErrorHandler(p_cmd,1,INVALID_PARAM);
      return NO_RESPONSE;
   }
}

/***********************************************************************/
/* END FUNCTION: DoIXEO                                                */
/***********************************************************************/



/***********************************************************************/
/* FUNCTION: IXOpcodes                                                 */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calls routines needed to implement the IX commands.        */
/*                                                                     */
/* RETURNED VALUE: none                                                */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* FILE SCOPE STATICS USED:                                            */
/*                                                                     */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/* WARNINGS:                                                           */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

INT16 IXOpcodes(CMD_TYPE  *p_cmd,BIT8  *p_resp_parm,U_INT16 max_resp_len)
{
INT16           parm_len;

   (void) max_resp_len;

   parm_len = NO_RESPONSE;

   switch( p_cmd->opcode.int_op )
   {
      case  MAKEINT('T','I'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFTI) : DoCmd(p_cmd,p_resp_parm,&mIBTI);
	break;
      case  MAKEINT('T','R'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFTR) : DoCmd(p_cmd,p_resp_parm,&mIBTR);
	break;
      case  MAKEINT('T','Z'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFTZ) : DoCmd(p_cmd,p_resp_parm,&mIBTZ);
	break;
      case  MAKEINT('C','R'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFCR) : DoCmd(p_cmd,p_resp_parm,&mIBCR);
	break;
      case  MAKEINT('G','P'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFGP) : DoCmd(p_cmd,p_resp_parm,&mIBGP);
	break;
      case  MAKEINT('G','V'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFGV) : DoCmd(p_cmd,p_resp_parm,&mIBGV);
	break;
      case  MAKEINT('S','P'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFSP) : DoCmd(p_cmd,p_resp_parm,&mIBSP);
	break;
      case  MAKEINT('C','P'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFCP) : DoCmd(p_cmd,p_resp_parm,&mIBCP);
	break;
      case  MAKEINT('P','P'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFPP) : DoCmd(p_cmd,p_resp_parm,&mIBPP);
	break;
      case  MAKEINT('D','P'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFDP) : DoCmd(p_cmd,p_resp_parm,&mIBDP);
	break;
      case  MAKEINT('V','I'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFVI) : DoCmd(p_cmd,p_resp_parm,&mIBVI);
	break;
      case  MAKEINT('C','I'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFCI) : DoCmd(p_cmd,p_resp_parm,&mIBCI);
	break;
      case  MAKEINT('T','C'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFTC) : DoCmd(p_cmd,p_resp_parm,&mIBTC);
	break;
      case  MAKEINT('M','S'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFMS) : DoCmd(p_cmd,p_resp_parm,&mIBMS);
	break;
      case  MAKEINT('R','C'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFRC) :
	  DoCmd(p_cmd,p_resp_parm,&mIBRC);
	break;
      case  MAKEINT('S','T'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	   DoStatus(p_cmd,p_resp_parm,&mIFST) :
	   DoStatus(p_cmd,p_resp_parm,&mIBST);
	break;
      case  MAKEINT('C','F'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	   DoCmd(p_cmd,p_resp_parm,&mIFCF) :DoCmd(p_cmd,p_resp_parm,&mIBCF);
	break;
      case  MAKEINT('C','W'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	   DoCmd(p_cmd,p_resp_parm,&mIFCW) : DoCmd(p_cmd,p_resp_parm,&mIBCW);
	break;
      case  MAKEINT('Z','W'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	   DoCmd(p_cmd,p_resp_parm,&mIFZW) : DoCmd(p_cmd,p_resp_parm,&mIBZW);
	break;
      case  MAKEINT('T','P'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	   DoCmd(p_cmd,p_resp_parm,&mIFTP) : DoCmd(p_cmd,p_resp_parm,&mIBTP);
	break;
      case  MAKEINT('P','I'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmd(p_cmd,p_resp_parm,&mIFPI) : DoCmd(p_cmd,p_resp_parm,&mIBPI);
        break;
      case  MAKEINT('F','I'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmd(p_cmd,p_resp_parm,&mIFFI) : DoCmd(p_cmd,p_resp_parm,&mIBFI);
        break;
      case  MAKEINT('N','Z'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmd(p_cmd,p_resp_parm,&mIFNZ) : DoCmd(p_cmd,p_resp_parm,&mIBNZ);
        break;
      case  MAKEINT('E','O'):
	parm_len = DoIXEO(p_cmd,p_resp_parm);
	break;

      case  MAKEINT('F','Z'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmdWithResponse(p_cmd,p_resp_parm,&mIFFZ) : DoCmdWithResponse(p_cmd,p_resp_parm,&mIBFZ);
        break;
      case  MAKEINT('Z','P'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmdWithResponse(p_cmd,p_resp_parm,&mIFZP) : DoCmdWithResponse(p_cmd,p_resp_parm,&mIBZP);
        break;
      case  MAKEINT('Z','S'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoStatus(p_cmd,p_resp_parm,&mIFZS) : DoStatus(p_cmd,p_resp_parm,&mIBZS);
        break;
      case  MAKEINT('A','C'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmd(p_cmd,p_resp_parm,&mIFAC) : DoCmd(p_cmd,p_resp_parm,&mIBAC);
        break;
      case  MAKEINT('Z','F'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmdWithResponse(p_cmd,p_resp_parm,&mIFZF) : DoCmdWithResponse(p_cmd,p_resp_parm,&mIBZF);
        break;
      case  MAKEINT('L','P'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmdWithResponse(p_cmd,p_resp_parm,&mIFLP) : DoCmdWithResponse(p_cmd,p_resp_parm,&mIBLP);
        break;
      case  MAKEINT('L','F'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmdWithResponse(p_cmd,p_resp_parm,&mIFLF) : DoCmdWithResponse(p_cmd,p_resp_parm,&mIBLF);
        break;
      case  MAKEINT('L','S'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoStatus(p_cmd,p_resp_parm,&mIFLS) : DoStatus(p_cmd,p_resp_parm,&mIBLS);
        break;
      case  MAKEINT('L','X'):
        parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
           DoCmdWithResponse(p_cmd,p_resp_parm,&mIFLX) : DoCmdWithResponse(p_cmd,p_resp_parm,&mIBLX);
        break;
      case  MAKEINT('T','W'):
	parm_len = (p_cmd->dsap.char_dsap[1] == 'F') ?
	  DoCmd(p_cmd,p_resp_parm,&mIFTW) : DoCmd(p_cmd,p_resp_parm,&mIBTW);
	break;
      default:
	 parm_len = NO_RESPONSE;
	 CmdErrorHandler(p_cmd,0,INVALID_OP);
	 break;
   }

   return parm_len;
}


/***********************************************************************/
/* END FUNCTION: IXOpcodes                                             */
/***********************************************************************/



/***********************************************************************/
/* FUNCTION: IX_Cmds                                                   */
/* ========                                                            */
/*                                                                     */
/* PURPOSE: calls function which executes a command if one is          */
/*          available on the command queue.                            */
/*                                                                     */
/* RETURNED VALUE: none                                                */
/*                                                                     */
/* GLOBALS USED:                                                       */
/*                                                                     */
/* FILE SCOPE STATICS USED:                                            */
/*                                                                     */
/*                                                                     */
/* CALLS:                                                              */
/*                                                                     */
/* LIMITATIONS:                                                        */
/*                                                                     */
/* WARNINGS:                                                           */
/*                                                                     */
/*                                                                     */
/***********************************************************************/

void IX_Cmds(void)
{
   ExecCmds(&IX_Cmd_Q,IXOpcodes);
}

/***********************************************************************/
/* END FUNCTION: IX_Cmds                                               */
/***********************************************************************/

